'use strict';

/* eslint-disable */
$(function () {

  var itemData = null
  getEvent(id)


  function getEvent(id){
    $.get('http://39.106.171.39:8011/mbl/Event/getEventItem?id='+id, function(data, status){
      $('#title').text(data.eventtitle)
      $('#content').text(data.eventtext)
    })
  }

  $("#e0").click(function(){
    getEvent(datas[0].eventid)
  });
  $("#e1").click(function(){
    getEvent(datas[1].eventid)
  });
  $("#e2").click(function(){
    getEvent(datas[2].eventid)
  });
  $("#e3").click(function(){
    getEvent(datas[3].eventid)
  });
  $("#e4").click(function(){
    getEvent(datas[4].eventid)
  });
  $("#e5").click(function(){
    getEvent(datas[5].eventid)
  });
  $("#e6").click(function(){
    getEvent(datas[6].eventid)
  });
  $("#e7").click(function(){
    getEvent(datas[7].eventid)
  });
  $("#e8").click(function(){
    getEvent(datas[8].eventid)
  });

  $("#search").click(function(){
  });




  // 分页
  var prev = $("#prev");
  prev.click(function () {
    // 获取路径参数
    if (page && Number(page) > 1) {
      page = Number(page) - 1;
      // window.location.href = window.location.pathname + "?page=" + page;
      if(now=='journals'){
        getJournals(page)
      }else if(now=='books'){
        getBooks(page)
      }else if(now=='patents'){
        getPatents(page)
      }
    }
  });
  var next = $("#next");
  next.click(function () {
    // 获取路径参数
    if (page<pageCount) {
      page = Number(page) + 1;
      // window.location.href = window.location.pathname + "?page="+page;
      if(now=='journals'){
        getJournals(page)
      }else if(now=='books'){
        getBooks(page)
      }else if(now=='patents'){
        getPatents(page)
      }
    }
  });
  function monthFilter(time) {
    if (!time) {
      return "";
    }
    const month = [
      "Jan.",
      "Feb.",
      "Mar.",
      "Apr.",
      "May",
      "June",
      "July",
      "Aug.",
      "Sept.",
      "Oct.",
      "Nov.",
      "Dec.",
    ];
    const monthStr = time.split("-")[1];
    const num = Number(monthStr);
    return month[num - 1];
  }
  function dayFilter(time) {
    if (!time) {
      return "";
    }
    return time.split("-")[2];
  }
  function timeEnFilter(time) {
    if (!time) {
      return "";
    }
    const month = [
      "Jan.",
      "Feb.",
      "Mar.",
      "Apr.",
      "May",
      "June",
      "July",
      "Aug.",
      "Sept.",
      "Oct.",
      "Nov.",
      "Dec.",
    ];
    const timeStr = time.split("-");
    const yearStr = timeStr[0];
    const monthStr = timeStr[1];
    const dayStr = timeStr[2];
    const num = Number(monthStr);
    return `${dayStr} ${month[num - 1]} ${yearStr}`;
  }


});
